import { createI18n } from 'vue-i18n';
import { lang } from '@/settings/designSetting';
import { LangEnum } from '@/enums/styleEnum';
import { StorageEnum  } from '@/enums/storageEnum';
import { getLocalStorage } from '@/utils';
import { LangStateType } from '@/store/modules/langStore/langStore.d'
import en from './en/index';
import zh from './zh/index';

const langStorage: LangStateType = getLocalStorage(StorageEnum.GO_LANG_STORE);

// 语言数组
export const langList = [
    {
      label: '中文',
      key: LangEnum.ZH
    },
    {
      label: 'English',
      key: LangEnum.EN
    }
]
  
  const i18n = createI18n({
    legacy: false,
    globalInjection:true,
    locale: langStorage || lang,
    fallbackLocale: langStorage || lang,
    messages: {
      [LangEnum.ZH]: zh,
      [LangEnum.EN]: en
    }
  })

export default i18n;